#include <stdio.h>

void log_fun(char *str, int *data, int len)
{
	int i;
	printf("\n%s:\n",str);
	for (i = 0; i < len; i++)
	{
		printf("%d\t",data[i]);
	}
	printf("\n");
}

void bubble_sort(int *data, unsigned int len)
{
	int i, j, temp;
	for (i = 0; i < len; i++)
	{
		for (j = 0; j < len - 1 - i; j++)
		{
			if (data[j] > data[j+1])
			{
				temp = data[j];
				data[j] = data[j+1];
				data[j+1] = temp;
			}
		}
	}
}

int main ()
{
	int Array[] = {1, 4, 7, 2, 5, 8, 3, 6, 9};
	unsigned int length = sizeof(Array) / sizeof(int);
	log_fun("RawData", Array, length);
	
	bubble_sort(Array,length);
	
	log_fun("Bubble Sort", Array, length);
	
	printf("\n---END---\n");
	return 0;
	
}